package com.danci.common;

import cn.hutool.http.HttpStatus;
import lombok.Data;

/**
 * 统一返回类
 */
@Data
public class Result {

    private Integer code;

    private String msg;

    private Object body;

    public Result(Integer code, String msg, Object body) {
        this.code = code;
        this.msg = msg;
        this.body = body;
    }

    public static Result success(Object body){
        return new Result(HttpStatus.HTTP_OK,"数据请求成功",body);
    }

    public static Result fail(){
        return new Result(HttpStatus.HTTP_INTERNAL_ERROR,"服务器异常",null);
    }
    public static Result fail(String msg){
        return new Result(HttpStatus.HTTP_INTERNAL_ERROR,msg,null);
    }

    public static Result customerBody(Integer code,String msg,Object body){
        return new Result(code, msg, body);
    }
}
